package com.shuzijun.leetcode.editor.cn;
public class FindSmallestLetterGreaterThanTarget{
    public static void main(String[] args) {
         Solution solution = new FindSmallestLetterGreaterThanTarget().new Solution();
    }
    //leetcode submit region begin(Prohibit modification and deletion)
class Solution {
    public char nextGreatestLetter(char[] letters, char target) {
       int low = 0;
       int high = letters.length-1;
       while (low <= high){
           int mid = low + (high - low) / 2;
           char c = letters[mid];
           if (c > target){
               if (mid == 0 || letters[mid-1] <= target){
                   return letters[mid];
               }else {
                   high = mid-1;
               }
           }else {
               low = mid+1;
           }
       }
        return letters[0];
    }
}
//leetcode submit region end(Prohibit modification and deletion)

}